﻿Public Class frmMain

    Public _Role As String
    Public _User As String
    Public _LawyerID As Long
    Dim isClose As Boolean = True

    Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        MessageBox.Show("User : " & _User & vbCrLf & "LawyerID : " & _LawyerID & vbCrLf & "Role :" & _Role)
        MenuVisible()
    End Sub

    Protected Sub MenuVisible()
        'Menu
        msFile.Visible = False
        msSetting.Visible = False
        msList.Visible = False
        msService.Visible = False
        msMore.Visible = False
        msIncome.Visible = False
        msHelp.Visible = False

        'Sub Menu
        smLogout.Visible = False
        smExit.Visible = False

        smCreateUser.Visible = False
        smChangePassword.Visible = False
        lsmUserList.Visible = False
        smUserList.Visible = False

        smEmployee.Visible = False
        smLawyer.Visible = False
        lsmEmployeeList.Visible = False
        smEmployeeList.Visible = False
        smLawyerList.Visible = False

        smContract.Visible = False
        smCase.Visible = False
        lsmContractList.Visible = False
        smContractList.Visible = False
        smCaseList.Visible = False

        smCourt.Visible = False
        smCaseCategory.Visible = False

        smIncome.Visible = False

        smHelp.Visible = False
        smAboutUs.Visible = False

        'Tool Str
    End Sub

    Private Sub tsShowHide_ItemClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.ToolStripItemClickedEventArgs) Handles tsShowHide.ItemClicked
        If tslblShowHide.Text = "បំបាំង" Then
            tsMenu.Visible = False
            tslblShowHide.Text = "បង្ហាញ"
        Else
            tsMenu.Visible = True
            tslblShowHide.Text = "បំបាំង"
        End If
    End Sub

    Private Sub ShowForm(ByVal frm As Form)
        For Each frmApproval As Form In Me.MdiChildren
            Try
                If frmApproval.Name <> frm.Name Then
                    frmApproval.Close()
                End If
            Catch ex As Exception
            End Try
        Next
        frm.MdiParent = Me
        frm.ControlBox = False
        frm.ShowIcon = False
        frm.WindowState = FormWindowState.Maximized
        frm.Show()
        frm.BringToFront()
    End Sub

    Private Sub smContract_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smContract.Click, tsContract.Click
        ShowForm(frmContractEntry)
    End Sub

    Private Sub smContractList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smContractList.Click
        ShowForm(frmContract)
    End Sub

    Private Sub smExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smExit.Click, tsExit.Click
        Application.Exit()
    End Sub

    Private Sub smLogout_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smLogout.Click, tsLogout.Click
        frmLogin.Show()
        isClose = False
        Close()
    End Sub

    Private Sub smEmployee_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smEmployee.Click
        ShowForm(frmEmployeeEntry)
    End Sub

    Private Sub smEmployeeList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smEmployeeList.Click
        ShowForm(frmEmployee)
    End Sub

    Private Sub smLawyer_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smLawyer.Click
        ShowForm(frmLawyerEntry)
    End Sub

    Private Sub smLawyerList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smLawyerList.Click
        ShowForm(frmLawyer)
    End Sub

    Private Sub smCreateUser_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smCreateUser.Click
        ShowForm(frmUserEntry)
    End Sub

    Private Sub smUserList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smUserList.Click
        ShowForm(frmUser)
    End Sub

    Private Sub smChangePassword_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smChangePassword.Click
        ShowForm(frmChangePassword)
    End Sub

    Private Sub smCase_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smCase.Click
        ShowForm(frmCaseEntry)
    End Sub

    Private Sub smCaseList_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smCaseList.Click
        ShowForm(frmCase)
    End Sub

    Private Sub smCaseCategory_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smCaseCategory.Click
        ShowForm(frmCaseCategory)
    End Sub

    Private Sub smCourt_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smCourt.Click
        ShowForm(frmCourt)
    End Sub

    Private Sub smIncome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles smIncome.Click
        ShowForm(frmCaseIncome)
    End Sub

    Private Sub frmMain_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
        If isClose Then
            Application.Exit()
        End If
    End Sub
End Class